<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改产品标签记录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-partsTag-edit" th:object="${zsyhPartsTag}">
            <input name="id" th:field="*{id}" type="hidden">
            <input id="factoryId" name="factoryId" th:field="*{factoryId}" class="form-control" type="hidden">
            <input id="partsId" name="partsId" th:field="*{partsId}" class="form-control" type="hidden">
            <input id="attributeId" name="attributeId" th:field="*{attributeId}" class="form-control" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">产品规格名称：</label>
                <div class="col-sm-8">
                    <input id="attributeName" name="attributeName" th:field="*{attributeName}" class="form-control" type="text" onclick="partsSelect()" readonly required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">厂家名称：</label>
                <div class="col-sm-8">
                    <input id="factoryName" name="factoryName" th:field="*{factoryName}" class="form-control" type="text" readonly>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">标签数量：</label>
                <div class="col-sm-8">
                    <input id="tagNumber" name="tagNumber" th:field="*{tagNumber}" class="form-control" type="text" onchange="updateMoney();" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">标签单价：</label>
                <div class="col-sm-8">
                    <input i="tagPrice" name="tagPrice" th:field="*{tagPrice}" class="form-control" type="text" onchange="updateMoney();" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">本次标签费用：</label>
                <div class="col-sm-8">
                    <input id="tagMoney" name="tagMoney" th:field="*{tagMoney}" class="form-control" type="text" readonly>
                </div>
            </div><div class="form-group">
                <label class="col-sm-3 control-label is-required">其他费用：</label>
                <div class="col-sm-8">
                    <input id="otherMoney" name="otherMoney" th:field="*{otherMoney}" class="form-control" type="text" >
                </div>
            </div><div class="form-group">
                <label class="col-sm-3 control-label is-required">合计费用：</label>
                <div class="col-sm-8">
                    <input id="allMoney" name="allMoney" th:field="*{allMoney}" class="form-control" type="text" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">备注：</label>
                <div class="col-sm-8">
                    <textarea id="tagRemark" name="tagRemark" th:field="*{tagRemark}" class="form-control" ></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/partsTag";
        $("#form-partsTag-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-partsTag-edit').serialize());
            }
        }

        function updateMoney() {
            debugger;
            var totalMoney=0;
            if(($("#tagNumber").val() != '' && $("#tagNumber").val() != null && $("#tagNumber").val() != undefined) && ($("#tagPrice").val() != '' && $("#tagPrice").val() != null && $("#tagPrice").val() != undefined)){
                totalMoney =($("#tagNumber").val() * $("#tagPrice").val() ).toFixed(2);
                $("#tagMoney").val(totalMoney);
            }

        }

        function partsSelect() {
            var url = ctx+"zsyh/parts/partsTag/";
            layer.open({
                type: 2,
                area: ['800px', '600px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "选择产品",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });

        }

    </script>
</body>
</html>